#pragma once
#include "room.h"
#include "Building.h"
#include <string>
#include <clocale>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <algorithm>
#include <memory>
using namespace std;

class BuildingDataBase : public vector<Building> 

{
public:

	BuildingDataBase()
	{
	}

	void ReadFromFilesToDatabase(string f)
	{
		this->clear(); 

		string str, strRow;
		ifstream fin(f);

		while (std::getline(fin, strRow))
		{
			Building bu;
			bu.ReadFromFile(strRow);
			if (bu.GetInfo().compare("") != 0) //
			{
				this->push_back(bu);
			}
		}
	}

	void WriteToFile(string file){

		for (auto &item : *this)
		{
			item.WriteToFile(file);
		}
		

	}

	string List()
	{
		string s = "";
		for (auto &item : *this)
		{
			s += "\n" + item.GetInfo() + "\n";
			s += item.list();
		}
		return s;
	}

	string SearchWordInInfo(string keyword)
	{
		string s = "";

		for (auto &item : *this)
		{
			s +=  item.SearchWordInInfo(keyword);
		}

		return s;
	}

	double Area(){
		double sum=0;
		for (auto &item : *this)
		{
			sum += item.Area();
		}
		return sum;
	}
	~BuildingDataBase()
	{
	}
};

